package com.fingard.dsp.bank.directbank.citic05.util;

import java.util.Collection;
import java.util.Vector;

public class AppException
        extends Exception
{
    private Vector vecErrMsg;
    private Exception exception;

    public AppException(String errorMsg)
    {
        this.exception = null;
        this.vecErrMsg = new Vector(2);
        this.vecErrMsg.add(errorMsg);
    }

    public AppException(String errorMsg, AppException ex)
    {
        this(errorMsg);
        setStackTrace(ex.getStackTrace());
        this.vecErrMsg.addAll(ex.getErrorList());
        this.exception = ex.getException();
    }

    public AppException(String errorMsg, Exception ex)
    {
        this(errorMsg);
        setStackTrace(ex.getStackTrace());
        String msg = ex.getMessage();
        if ((null != msg) && ((msg.length() == 7) || ((msg.length() > 7) && (' ' == msg.charAt(7))))) {
            this.vecErrMsg.add(msg);
        }
        this.exception = ex;
    }

    public String getMessage()
    {
        return (String)this.vecErrMsg.firstElement();
    }

    public Collection getErrorList()
    {
        return this.vecErrMsg;
    }

    public String getAllMessage()
    {
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < this.vecErrMsg.size(); i++)
        {
            result.append((String)this.vecErrMsg.get(i));
            if (i != this.vecErrMsg.size() - 1) {
                result.append("\r\n");
            }
        }
        return result.toString();
    }

    public Exception getException()
    {
        return this.exception;
    }
}
